package com.daodao.daodaoschedule.infrastructure.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.Map;

/**
 * @author mal
 * @date 2022-11-23 14:32
 */
@RestControllerAdvice
public class BaseExceptionHandler {
    private static final Logger logger = LoggerFactory.getLogger(BaseExceptionHandler.class);

    @org.springframework.web.bind.annotation.ExceptionHandler(Exception.class)
    public Map error(Exception e) {
        logger.error("",e);
        HashMap<String, Object> map = new HashMap<>();
        map.put("error", 1);
        map.put("msg", e.getMessage());
        return map;

    }
}
